import Vue from 'vue'
import Vuex from 'vuex'

import userSotre from '../store/user'
import gameSotre from '../store/GameList.js'

Vue.use(Vuex)

const store = new Vuex.Store({
	state: {
		/**
		 * 是否需要强制登录
		 */
		forcedLogin: false,
		hasLogin: false,
		tempList: [],
	},

	modules: {
		userSotre,
		gameSotre
	},

	mutations: {
		login(state, userName) {
			state.userName = userName || '新用户';
			state.hasLogin = true;
		},

		logout(state) {
			state.userName = "";
			state.hasLogin = false;
		},

		updateList(state, tempList) {
			state.tempList = tempList || [];
		},
	}
})

export default store
